package util

import (
	commonUtil "bgs/util"
	"go.uber.org/zap"
)

// NoopNSQLogger allows us to pipe NSQ logs to dev/null
// The default NSQ logger is great for debugging, but did
// not fit our normally well structured JSON logs. Luckily
// NSQ provides a simple interface for injecting your own
// logger.
type NoopNSQLogger struct {
	slog *zap.SugaredLogger
}

func NewNoopNSQLogger(slog *zap.SugaredLogger) *NoopNSQLogger {
	return &NoopNSQLogger{slog: slog}
}

// Output allows us to implement the nsq.Logger interface
func (l *NoopNSQLogger) Output(calldepth int, s string) error {
	if !commonUtil.Contains(s, "TOPIC_NOT_FOUND") {
		l.slog.Errorf("nsqerr:%s", s)
	}
	return nil
}
